﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Model;
using DAL;

public partial class Student_Register : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void BtnRegister_Click(object sender, EventArgs e)
    {
        Student student = new Student();
        student.Id = Guid.NewGuid().ToString();//用GUID生成id
        student.StuId = StuId.Text.ToUpper();
        student.Name=Name.Text;
        student.Password = Password.Text;
        student.ClassIn=ClassIn.SelectedItem.Text;
        student.Sex = Sex.Text;
        student.Age = int.Parse(Age.Text);
        student.Email = Email.Text;
        student.Phone=Phone.Text;
        student.ScurityNo = SecurityNo.Text;
        student.RegisterDate = DateTime.Now;
        

        StudentManager studentManager = new StudentManager();
        if(!studentManager.ExistsStuId(student.StuId)){
            studentManager.Add(student);
            msg.Text = "<font color='green'>注册成功!</font>";
            FormStudentRegister.Visible = false;
            msg.Visible = true;
        }else{
            msg.Text = "<font color='red'>注册失败,该学号已经存在！</font>";
            msg.Visible = true;
        }

        
    }
}
